from environs import Env
from telebot import TeleBot

import httpx

env = Env()
env.read_env()

TELEGRAM_BOT_TOKEN = env('TELEGRAM_BOT_TOKEN')
WEBHOOK_URL = env('WEBHOOK_URL')
WEBHOOK_TOKEN = env('WEBHOOK_TOKEN')
CHAT_ID = env('CHAT_ID')


def main():
    bot = TeleBot(TELEGRAM_BOT_TOKEN)
    
    bot.remove_webhook()
    bot.set_webhook(url=f'https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/setWebhook?url={WEBHOOK_URL+WEBHOOK_TOKEN}')
    web_hook = bot.get_webhook_info()
    print(web_hook)

    params = {
        'chat_id': CHAT_ID,
        'text': 'Я есть бот. Моя знать про тебя',
    }

    response = httpx.get(f'https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage', params=params)
    print(response.json())

if __name__ == '__main__':
    main()